initCurDate();

//获取系统时间
function initCurDate() {
    let timetext = document.getElementById("time-text");
    let weektext = document.getElementById("week-text");
    let datetext = document.getElementById("date-text");
    setInterval(function() {
        let time = new Date();
        let h = time.getHours();
        let mi = time.getMinutes();
        if (h < 10) {
            h = '0' + h;
        }
        if (mi < 10) {
            mi = '0' + mi;
        }
        let t = h + ":" + mi;
        timetext.innerHTML = t;

        let m = time.getMonth() + 1;
        let da = time.getDate() + 0;
        if (m < 10) {
            m = '0' + m;
        }
        if (da < 10) {
            da = '0' + da;
        }
        let d = time.getFullYear() + "." + m + "." + da;
        datetext.innerHTML = d;

        let w = time.getDay();
        if (w == '0') {
            w = '星期天';
        } else if (w == '1') {
            w = '星期一';
        } else if (w == '2') {
            w = '星期二';
        } else if (w == '3') {
            w = '星期三';
        } else if (w == '4') {
            w = '星期四';
        } else if (w == '5') {
            w = '星期五';
        } else if (w == '6') {
            w = '星期六';
        }
        weektext.innerHTML = w;
    }, 1000);
}
